%{
#include <stdio.h>
#include "yacc.tab.h"
#include "symtable.h"
extern int yylex();
int linenum = 1;
%}

symbol [a-zA-Z][a-zA-Z0-9_]*
number [0-9]+

%option noyywrap

%%

 /* ignore comments */
#.*		;

 /* keywords */
int		{ return DD_KEYWORD_INT; }
float		{ return DD_KEYWORD_FLOAT; }
struct		{ return DD_KEYWORD_STRUCT; }
override	{ return DD_KEYWORD_OVERRIDE; }
if		{ return DD_KEYWORD_IF; }
void		{ return DD_KEYWORD_VOID; }

 /* operators */
\=\=		{ return DD_OPERATOR_EQ; }
\<\=		{ return DD_OPERATOR_LE; }
\>\=		{ return DD_OPERATOR_GE; }

 /* constants and variables */
{symbol}	{ yylval = symtable_insert(yytext, DD_CONSTANT_SYMBOL); return DD_CONSTANT_SYMBOL; }
\".*\"		{ yylval = symtable_insert(yytext, DD_CONSTANT_STRING); return DD_CONSTANT_STRING; }
{number}	{ yylval = atoi(yytext); return DD_CONSTANT_NUMBER; }

 /* pass-through text */
[-/*;=+{}():\.><]	return yytext[0];

 /* ignore whitespace */
[ \t]		;

 /* count lines */
\n		linenum++;

%%
